<form  method="post" id="config_form" class="form-horizontal">
    <input type="hidden" name="id" value="{$privilege.id}">
    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label"></label>
        <div class="col-md-6 col-xs-12">
            <h2>系统设置</h2>
        </div>
    </div>
    <!--<div class="form-group">-->
        <!--<label class="col-md-3 col-xs-12 control-label">提现手续费设置(固定值)</label>-->
        <!--<div class="col-md-6 col-xs-12">-->
            <!--<input name="config[withdrawal_poundage]" type="number" id="withdrawal_poundage" class="form-control" value="{$config['withdrawal_poundage']}"/>-->
        <!--</div>-->
    <!--</div>-->

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">获胜系统抽成(钻石金币比例)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[win_system_poundage]" type="number" id="win_system_poundage" class="form-control" value="{$config['win_system_poundage']}"/>
        </div>
    </div>

    <!--<div class="form-group">-->
        <!--<label class="col-md-3 col-xs-12 control-label">获胜代理抽成(积分比例)</label>-->
        <!--<div class="col-md-6 col-xs-12">-->
            <!--<input name="config[win_agency_poundage]" type="number" id="win_agency_poundage" class="form-control" value="{$config['win_agency_poundage']}"/>-->
        <!--</div>-->
    <!--</div>-->

    <!--<div class="form-group">-->
        <!--<label class="col-md-3 col-xs-12 control-label">解散房间扣除手续费(固定值)</label>-->
        <!--<div class="col-md-6 col-xs-12">-->
            <!--<input name="config[disband_poundage]" type="number" id="disband_poundage" class="form-control" value="{$config['disband_poundage']}"/>-->
        <!--</div>-->
    <!--</div>-->
    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">解散房间扣除金币(比例)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[disbanded_gold_number]" type="number" id="disbanded_gold_number" class="form-control" value="{$config['disbanded_gold_number']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">解散房间扣除钻石(比例)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[disbanded_integral_number]" type="number" id="disbanded_integral_number" class="form-control" value="{$config['disbanded_integral_number']}"/>
        </div>
    </div>


    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">签到赠送的金币(固定值)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[check_in_gold]" type="number" id="check_in_gold" class="form-control" value="{$config['check_in_gold']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">抽奖需要的金币(固定值)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[lottery_gold]" type="number" id="lottery_gold" class="form-control" value="{$config['lottery_gold']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">推广成功获得的金币数(固定值)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[promotion_gold]" type="number" id="promotion_gold" class="form-control" value="{$config['promotion_gold']}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">新用户注册奖励的钻石数(固定值)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[register_reward_integral]" type="number" id="register_reward_integral" class="form-control" value="{$config['register_reward_integral']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">房间创建后超过N分钟未进行解散(固定值，分钟)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[disbanded_room_time]" type="number" id="disbanded_room_time" class="form-control" value="{$config['disbanded_room_time']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">摆擂页面顶部图片(375*185)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[add_room_image]" type="text" id="add_room_image" class="form-control" value="{$config['add_room_image']}" readonly/>
            <button type="button" class="btn btn-block btn-info pull-right" data-id="add_room_image" onclick="uploadImageByObj(this)"> 上传 </button>
            <button type="button" class="btn btn-block btn-info pull-right" data-id="add_room_image" onclick="imageClick(this)"> 查看 </button>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">胜率榜上榜所需场次数</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[screenings]" type="number" id="screenings" class="form-control" value="{$config['screenings']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">用户浏览量比例(例如：5：1输入0.2)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[pageviews_proportion]" type="number" id="pageviews_proportion" class="form-control" value="{$config['pageviews_proportion']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">用户浏览量换钱比例(例如:0.3)</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[pageviews_to_money]" type="number" id="pageviews_to_money" class="form-control" value="{$config['pageviews_to_money']}"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">不同段位是否能比赛</label>
        <div class="col-md-6 col-xs-12">
            <eq name="config['diff_level_match']" value="0">
                <label>
                    <input type="radio" name="config[diff_level_match]" value="1">能
                </label>
                <label>
                    <input type="radio" name="config[diff_level_match]" value="0" checked>不能
                </label>
                <else/>
                <input type="radio" name="config[diff_level_match]" value="1" checked>能
                <input type="radio" name="config[diff_level_match]" value="0">不能
            </eq>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-3 col-xs-12 control-label">场次榜上榜所需场次数</label>
        <div class="col-md-6 col-xs-12">
            <input name="config[battle_times]" type="number" id="battle_times" class="form-control" value="{$config['battle_times']}"/>
        </div>
    </div>

    <div>
        <div class="col-md-3 col-xs-12"></div>
        <div class="col-md-6 col-xs-12">
            <present name="errorNote">
                <div class="alert alert-danger" role="alert">
                    <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <strong>{$errorNote}</strong>
                </div>
            </present>
            <div class="form-group">
                <div class="col-md-6"><input type="reset" class="btn btn-block btn-default" value=" 清 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 空 " /></div>
                <div class="col-md-6"><button type="button" class="btn btn-block btn-info pull-right" onclick="edit()"> 提 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 交 </button></div>
            </div>
        </div>
    </div>
    <!-- Modal -->
    <div class="modal fade" id="hint_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="hint_content">
                </div>
                <div class="modal-footer">
                    <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <!--<button type="button" class="btn btn-primary">Save changes</button>-->
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="image_alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">图片)</h4>
                </div>
                <div class="modal-body" id="image_content">
                    <img id="image_path" style="width: 100%"/>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <!--<button type="button" class="btn btn-primary">Save changes</button>-->
                </div>
            </div>
        </div>
    </div>
</form>
<include file="Public:bootstrapUpload"/>
<script type="text/javascript">

    function uploadImageByObj(obj){
        var id = $(obj).data('id');
        var url = '__APP__/Admin/Public/upload';
//        uploadImage(id);
        initFileInput(id,url);
        $('#uploadModal').modal();
    }

    function imageClick(obj) {
        var id = $(obj).data('id');
        var imageUrl = $('#'+id).val();
        $('#image_path').attr('src','__ROOT__/'+imageUrl);
        $('#image_alert').modal('show');
    }

    function edit() {
        $.ajax({
            type: "POST",
            url: "__URL__/edit",
            data:  $("#config_form").serialize(),
            dataType: "json",
            success: function (data) {
                console.info(data);
                $("#hint_content").empty().append(data.message);
                $("#hint_modal").modal();
            },
            error: function (data) {
                $("#hint_content").empty().append("请求超时！");
                $("#hint_modal").modal();
            }
        });
    }
</script>